<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专辑列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>专辑名称：</p>
                                <input type="text" name="title"/>
                            </li>
                            <li>
                                <p>类型：</p>
                                <select name="type">
                                    <option value="">所有</option>
                                    <option value="1">电影</option>
                                    <option value="2">电视剧</option>
                                    <option value="3">动漫</option>
                                    <option value="4">体育</option>
                                    <option value="5">娱乐</option>
                                    <option value="6">游戏</option>
                                    <option value="9">纪录片</option>
                                    <option value="10">综艺</option>
                                    <option value="22">音乐</option>
                                    <option value="23">新闻</option>
                                    <option value="25">时尚</option>
                                    <option value="26">旅游</option>
                                    <option value="27">教育</option>
                                    <option value="28">科技</option>
                                    <option value="29">汽车</option>
                                    <option value="31">生活</option>
                                    <option value="50">合作</option>
                                    <option value="60">母婴</option>
                                    <option value="106">少儿</option>
                                    <option value="-1">未知</option>
                                </select>
                            </li>
                            <li>
                                <p>状态：</p>
                                <select name="status">
                                    <option value="">所有</option>
                                    <option value="0">未分配</option>
                                    <option value="1">已分配</option>
                                </select>
                            </li>
                            <!--<li>-->
                                <!--<p>所属团队：</p>-->
                                <!--<input type="text" name="teamId"/>-->
                            <!--</li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="media:album:add">-->
                    <!--<i class="fa fa-plus"></i> 添加-->
                <!--</a>-->
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="media:album:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="media:album:remove">-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <a class="btn btn-primary multiple disabled" onclick="assignTeamAll()" shiro:hasPermission="media:album:assignTeam">
                    <i class="fa fa-edit"></i> 批量分配
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="media:album:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var assignTeamFlag = [[${@permission.hasPermi('media:album:assignTeam')}]];
        var prefix = ctx + "media/album";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "专辑",
                detailFormatter: detailFormatter,
                detailView: true,
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '主键',
                    visible: false
                },
                {
                    field : 'cid', 
                    title : 'cid'
                },
                {
                    field : 'title', 
                    title : '专辑名称'
                },
                {
                    field : 'description',
                    title : '简介',
                    visible: false,
//                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field : 'type', 
                    title : '类型',
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '<span class="badge badge-danger">电影</span>';
                        } else if (value == '2') {
                            return '<span class="badge badge-danger">电视剧</span>';
                        } else if (value == '3') {
                            return '<span class="badge badge-danger">动漫</span>';
                        } else if (value == '4') {
                            return '<span class="badge badge-danger">体育</span>';
                        } else if (value == '5') {
                            return '<span class="badge badge-danger">娱乐</span>';
                        } else if (value == '6') {
                            return '<span class="badge badge-danger">游戏</span>';
                        } else if (value == '9') {
                            return '<span class="badge badge-danger">纪录片</span>';
                        } else if (value == '10') {
                            return '<span class="badge badge-danger">综艺</span>';
                        } else if (value == '22') {
                            return '<span class="badge badge-danger">音乐</span>';
                        } else if (value == '23') {
                            return '<span class="badge badge-danger">新闻</span>';
                        } else if (value == '25') {
                            return '<span class="badge badge-danger">时尚</span>';
                        } else if (value == '26') {
                            return '<span class="badge badge-danger">旅游</span>';
                        } else if (value == '27') {
                            return '<span class="badge badge-danger">教育</span>';
                        } else if (value == '28') {
                            return '<span class="badge badge-danger">科技</span>';
                        } else if (value == '29') {
                            return '<span class="badge badge-danger">汽车</span>';
                        } else if (value == '31') {
                            return '<span class="badge badge-danger">生活</span>';
                        } else if (value == '50') {
                            return '<span class="badge badge-danger">合作</span>';
                        } else if (value == '60') {
                            return '<span class="badge badge-danger">母婴</span>';
                        } else if (value == '106') {
                            return '<span class="badge badge-danger">少儿</span>';
                        } else if (value == '-1'){
                            return '<span class="badge badge-danger">未知</span>';
                        }
                    }
                },
                {
                    field : 'copyright', 
                    title : '出品方'
                },
                {
                    field : 'langue', 
                    title : '语言'
                },
                {
                    field : 'director', 
                    title : '导演'
                },
                {
                    field : 'episodeAll', 
                    title : '总集数'
                },
                {
                    field : 'episodeUpdated', 
                    title : '更新集数'
                },
                {
                    field : 'score', 
                    title : '评分'
                },
                {
                    field : 'leadingActor', 
                    title : '主演',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field : 'areaName', 
                    title : '地区',
                    visible: false
                },
                {
                    field : 'year', 
                    title : '年份',
                    visible: false
                },
                {
                    field : 'newPicVt', 
                    title : '竖版海报',
                    visible: false
                },
                {
                    field : 'newPicHz', 
                    title : '横版海报',
                    visible: false
                },
                {
                    field : 'publishDate', 
                    title : '上映日期',
                    visible: false
                },
                {
                    field : 'createTime',
                    title : '创建时间'
                },
                {
                    field : 'status',
                    title : '状态',
                    formatter: function(value, row, index) {
                        if (value == '0') {
                            return '<span class="badge badge-warning">未分配</span>';
                        } else if (value == '1') {
                            return '<span class="badge badge-info">已分配</span>';
                        }
                    }
                },
                {
                    field : 'teamName',
                    title : '审核组'
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.status == 0){
                            actions.push('<a class="btn btn-primary btn-xs ' + assignTeamFlag + '" href="javascript:void(0)" onclick="assignTeam(\'' + row.id + '\')"><i class="fa fa-share-square"></i>分配任务</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //展开显示
        function detailFormatter(index, row) {
            var html = [];
            $.each(row, function (key, value) {
                if (key != '0' && key != 'params') {
                    if ((key == 'newPicHz' || key == 'newPicHz') && $.common.isNotEmpty(value)) {
                        key = '海报';
                        html.push('<p><b>' + key + ':</b> <a class="btn btn-primary btn-xs" href="javascript:;" onclick="preview(\'' + key + '\', \'' + value + '\')"><i class="fa fa-image"></i>预览图片</a></p>');
                    } else {
                        if (value == null) {
                            value = '-';
                        }
                        if (key == 'searchValue'){
                            return;
                        }
                        if (key == 'createBy'){
                            return;
                        }
                        if (key == 'createTime'){
                            return;
                        }
                        if (key == 'updateBy'){
                            return;
                        }
                        if (key == 'updateTime'){
                            return;
                        }
                        if (key == 'remark'){
                            return;
                        }
                        if (key == 'teamId'){
                            return;
                        }
                        if (key == 'secondTitle'){
                            return;
                        }
                        if (key == 'tag'){
                            return;
                        }
                        if (key == 'newPicVt'){
                            return;
                        }
                        if (key == 'cid'){
                            key = '专辑ID';
                        }
                        if (key == 'title'){
                            key = '专辑名称';
                        }
                        if (key == 'type'){
                            key = '类型';
                            if (value == '1') {
                                value = '电影';
                            } else if (value == '2') {
                                value = '电视剧';
                            } else if (value == '3') {
                                value = '动漫';
                            } else if (value == '4') {
                                value = '体育';
                            } else if (value == '5') {
                                value = '娱乐';
                            } else if (value == '6') {
                                value = '游戏';
                            } else if (value == '9') {
                                value = '纪录片';
                            } else if (value == '10') {
                                value = '综艺';
                            } else if (value == '22') {
                                value = '音乐';
                            } else if (value == '23') {
                                value = '新闻';
                            } else if (value == '25') {
                                value = '时尚';
                            } else if (value == '26') {
                                value = '旅游';
                            } else if (value == '27') {
                                value = '教育';
                            } else if (value == '28') {
                                value = '科技';
                            } else if (value == '29') {
                                value = '汽车';
                            } else if (value == '31') {
                                value = '生活';
                            } else if (value == '50') {
                                value = '合作';
                            } else if (value == '60') {
                                value = '母婴';
                            } else if (value == '106') {
                                value = '少儿';
                            } else if (value == '-1'){
                                value = '未知';
                            }
                        }
                        if (key == 'copyright'){
                            key = '出品方';
                        }
                        if (key == 'langue'){
                            key = '语言';
                        }
                        if (key == 'director'){
                            key = '导演';
                        }
                        if (key == 'description'){
                            key = '简介';
                        }
                        if (key == 'episodeAll'){
                            key = '总集数';
                        }
                        if (key == 'episodeUpdated'){
                            key = '更新集数';
                        }
                        if (key == 'score'){
                            key = '评分';
                        }
                        if (key == 'leadingActor'){
                            key = '主演';
                        }
                        if (key == 'areaName'){
                            key = '地区';
                        }
                        if (key == 'year'){
                            key = '年份';
                        }
                        if (key == 'publishDate'){
                            key = '上映日期';
                        }
                        if (key == 'teamName'){
                            key = '审核组';
                        }
                        if (key == 'status'){
                            key = '状态';
                            if (value == '0'){
                                value = '未分配';
                            }else if (value == '1'){
                                value = '已分配';
                            }
                        }
                        html.push('<div style="width:1080px;word-wrap:break-word"><p><b>' + key + ':</b>' + value + '</p></div>');
                    }
                }
            });
            return html.join('');
        }

        //海报预览
        function preview(key, path) {
            var size = [0, 120, 140, 160, 175, 226, 332, 408, 498, 556, 1920];
//            if (key == 'newPicHz') {
//                size = [0, 75, 92, 116, 130, 161, 175, 220, 260, 350, 450, 770];
//            }
//            if (key == 'newPicHz') {
//                size = [0, 120, 140, 160, 175, 226, 332, 408, 498, 556, 1920];
//            }
            var obj = {
                "status": 1,
                "msg": "",
                "title": "图片预览",
                "start": 0
            };
            var data = [];
            for (var i = 0; i < size.length; i++) {
                var picObj = {
                    'alt': size[i] + ".jpg",
                    'pid': i,
//                    'src': staticHost + path + '/' + size[i] + ".jpg",
                    'src': path,
                    'thumb': ""
                };
                data.push(picObj)
            }
            obj.data = data;
            layer.photos({
                photos: obj,
                anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
            });
        }

        //分配专辑给审核小组
        function assignTeam(id) {
            var assignTeamUrl = ctx + "media/album/assignTeam/" + id;
            $.modal.open("专辑分配", assignTeamUrl);
        }

        // 分配专辑给审核小组  批量
        function assignTeamAll() {
            var rows = $.table.selectColumns("id");
            var assignTeamUrl = ctx + "media/album/assignTeam/" + rows;
            $.modal.open("专辑分配", assignTeamUrl);
        }
    </script>
</body>
</html>